home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / Sources / src / viewrc / tok2h.awk < prev    next >
Encoding:
AWK Script  |  1996-09-27  |  1.1 KB  |  37 lines

  1. BEGIN {
  2. #   Sorry, but most awk's are not able to deal with double quotes...
  3.   doublequote=sprintf("%c",34);
  4.   #{{{}}}
  5. #  {{{  print auto-gen-mark
  6.   print("/* This file is generated automatically by awk -f tok2h.awk */\n/* containing the token-name-list for viewrc */")
  7. #  }}}
  8.   printf("char const * const dec[]=\n")
  9.   print(" { "doublequote"O_NOP"doublequote",")
  10. #  {{{  init fixed cmd arg range
  11.   cmd_range=8
  12. #  }}}
  13. }
  14. #{{{  set fixed cmd arg range
  15. /^#define +FIXED_COMMAND_RANGE/ {
  16.   cmd_range=$3
  17. }
  18. #}}}
  19. #{{{  set types for command and fixed command
  20. $3=="COM" || $3=="COM_I" || $3=="COM_II" || $3=="COM_P" || $3=="COM_IP" || $3=="COM_IIP" || $3=="COM_C" { typ=$3;fix_typ="" }
  21. $3=="COM_A" { typ="COM_A";fix_typ="COM" }
  22. $3=="COM_ID" { typ="COM_II";fix_typ="COM_I" }
  23. $3=="COM_D" { typ="COM_I";fix_typ="COM" }
  24. #}}}
  25. #{{{  add command
  26. substr($1,1,1)!="#" && $3!="OCL-KEY" && $3!="OPP-KEY" {
  27.   if (fix_typ!="") {
  28.      for (i=cmd_range;i>0;i--) print("   "doublequote $1"_M"i doublequote",")
  29.      for (i=0;i<=cmd_range;i++) print("   "doublequote $1"_"i doublequote",")
  30.   }
  31.   print("   "doublequote $1 doublequote",")
  32. }
  33. #}}}
  34. END {
  35.   print("   "doublequote doublequote"\n };")
  36. }
  37.